// void, Obj me

Unit this;
Obj target;

this = me.AsUnit();
target = .RamBestTarget();

if (!target.IsValid()){
	Query RamTarget;
	
	Sleep(100);
	RamTarget = Intersect(Union(ObjsInSight(this, "Outpost"), ObjsInSight(this, "Gate")), EnemyObjs(.player, "Building"));
	if(RamTarget.count > 0){
		ObjList RamTargetList;
		
		RamTargetList = RamTarget.GetObjList();
		target = RamTargetList[0];
		if (!target.IsValid()) 
			while (1) Sleep(150000);
	} else {
		while (1) Sleep(150000);
	}
}
	
if (target.AsBuilding().IsBroken())
	while (1) Sleep(150000);

Sleep(100);

.SetCommand("attack", target);

